<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>Class Breakdown</title>
  <link rel="stylesheet" type="text/css" href="css/WeVal_Master_CSS.css"/>
  <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"/>
  <script language="javascript" type="text/javascript" src="javascripts/teacher-dashboard.js"/>
  <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"/>
  <script language="javascript" type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"/>
  <script language="javascript" type="text/javascript">
  </script>
  <script language="javascript" type="text/javascript">
	
		function bindButtons()
		{
			$(".button").click(function(){

				$(this).val("-");

				$(this).siblings(".toggleOpen").toggle();
			});
		}
		
		function expandAllQuestions()
		{
//			boolean expand = false;
//			if ($('#expandAllQuestions').is(':checked')){
//				$('#expandAllQuestions').val('collapse all');
//			} else {
//				expand = true;
//				$("#txtAge").hide();
//			} 
		}
		totalQuestions
    $("#StatisticsWrapper").before('<img id="loadinggif" src="http://usa.d-mpro.com/Assets/images/loadinglogin.gif" />');
		
    function getPixelLength(score)
    {
      var result = 0;
      result = score/4.00;
      result = 400*result;
      return result;
    }
		
    function getPixelLengthBasic()
    {
      var result = [];
      result.push(getAnswerLength(window.currentSD));
      result.push(getAnswerLength(window.currentD));
      result.push(getAnswerLength(window.currentN));
      result.push(getAnswerLength(window.currentA));
      result.push(getAnswerLength(window.currentSA));
      return result;		
    }
		
    function getAnswerLength(answerCount)
    {
      if(answerCount == 0 || window.currentTotal == 0)
      {
        return 0;
      }
      var returnValue = ((answerCount/window.currentTotal) * window.totalBarLength);
      return returnValue;
    }
		
		function appendQuestion()
		{
			var buildString = '<div class="question_box"><button id="' + questionCollapserId + '" class="button">+</button><div class="toggle">';
			buildString += '<div class="question">'+window.currentQuestion+'</div><div class="question_graph">';
			buildString += '<div class="graph_box graphStronglyDisagree" style=" width:'+window.currentLengths[0]+'px;">';
			buildString += '</div><div class="graph_box graphDisagree" style=" width:'+window.currentLengths[1]+'px;">';
			buildString += '</div><div class="graph_box graphNeutral" style=" width:'+window.currentLengths[2]+'px;">';
			buildString += '</div><div class="graph_box graphAgree" style=" width:'+window.currentLengths[3]+'px;">';
			buildString += '</div><div class="graph_box graphStronglyAgree" style=" width:'+window.currentLengths[4]+'px;">';
			buildString += '</div></div><table class="question_scores"><tr><td class="question_answers_collapsed">SD: '+window.currentSD+'</td>';
			buildString += '<td class="question_answers_collapsed">D: '+window.currentD+'</td>';
			buildString += '<td class="question_answers_collapsed">N: '+window.currentN+'</td>';
			buildString += '<td class="question_answers_collapsed">A: '+window.currentA+'</td>';
			buildString += '<td class="question_answers_collapsed">SA: '+window.currentSA+'</td>';
			buildString += '</tr></table><br/></div><div class="toggleOpen">TEST</div></div>';			
			$("#questions_wrapper").append(buildString);	
		}

		function essayQuery(crn, semester, year){
			
			jQuery.get('https://chitester1dev.weber.edu:6838/misc/weber/CSEvals/essayAnswers.cfm?crn='+crn+'&semester='+semester+'&year='+year+'&testId='+testId, function(data) {
			
				var numberOfStudents = 0;
				var questionsAndResponses = [];
				var questionIndex = 0;
				
				// Get number of students and create the array
				$.each(data.DATA, function(i,array) {
				
					var tempArray = [];
									
					var questionFound = false;
				
					for(var questionData = 0; questionData < questionsAndResponses.length; questionData++){
					
						if(array[5] == questionsAndResponses[questionData][0]){
						
							questionFound = true;
							break;
						
						}
					
					}
					
					if(questionFound == false){
				
						tempArray[0] = array[5];

						questionsAndResponses[questionIndex] = tempArray;
						questionIndex++;
					}
				
					if(array[7] > numberOfStudents){
					
						numberOfStudents = array[7];
					
					}
				
				});
						
				for(var studentNum = 0; studentNum < numberOfStudents; studentNum++){
					
					for(var q = 0; q < questionsAndResponses.length; q++){
					
						var studentResponseFound = false;					
					
						$.each(data.DATA, function(i,array) {
						
							if(questionsAndResponses[q][0] == array[5] && studentNum == array[7]){
																						
									questionsAndResponses[q].push(array[6]);
									studentResponseFound = true;
									return false;
																					
							}
						
						});
						
						if(!studentResponseFound){
							questionsAndResponses[q].push("No Response");
						}
					
					}
				
				}
				
				var eQuestions = "";
				
				for(var printQuestion = 0; printQuestion < questionsAndResponses.length; printQuestion++){
				
					var tempArray = questionsAndResponses[printQuestion];
					eQuestions += "<div class='question_box'><table class='essay_table_settings'><tr><td align='right'>#"+ (printQuestion + 1) + "</td><td></td><td align='left'>" + tempArray[0] + "</td></tr>"
					
					for(var responses = 1; responses < tempArray.length; responses++){
					
						var noResponse = "";
						
						if(tempArray[responses] == "No Response"){
							
							noResponse = "font-style:italic";
							
						}
					
						eQuestions += "<tr><td style='font-weight:normal;'>&nbsp;&nbsp;" + responses + "</td><td align='right'></td><td align='left' class='essay_responses' style='" + noResponse + "'>" + tempArray[responses] + "</td></tr>"
						
					}
					
					eQuestions += "</table></div>"
			
				}
				$("#EssayWrapper").append(eQuestions);
			
			});
		
		}
/*		
		function essayQuery(crn, semester, year){
	
			jQuery.get('https://chitester1dev.weber.edu:6838/misc/weber/CSEvals/essayAnswers.cfm?crn='+crn+'&semester='+semester+'&year='+year+'&testId='+testId, function(data) {
				
				var essayQuestionArray = [];

				$.each(data.DATA, function(i,array) {
					
					var tempArray = [];
					var questionIndex = -1;
					
					for(var question = 0; question < essayQuestionArray.length; question++){
					
						// If this question already has response, add the current iteration's answer
						if(array[5] == essayQuestionArray[question][0]){

							tempArray = essayQuestionArray[question];
							tempArray.push(array[6]);
							questionIndex = question;
							break;
							
						}
					
					}
					
					if(questionIndex == -1){
					
						// array[5] = question text | array[6] = question response
						essayQuestionArray.push([array[5],array[6]]); 
					
					} else {
				
						// replace old array with the tempArray including all previous responses and the current array's response
						essayQuestionArray[questionIndex] = tempArray;
					
					}
				
				});
				
				var eQuestions = "";
				
				for(var printQuestion = 0; printQuestion < essayQuestionArray.length; printQuestion++){
				
					var tempArray = essayQuestionArray[printQuestion];
					eQuestions += "<div class='question_box'><table class='essay_table_settings'><tr><td align='right'>#"+ (printQuestion + 1) + "</td><td></td><td align='left'>" + tempArray[0] + "</td></tr>"
					
					for(var responses = 1; responses < tempArray.length; responses++){
					
						eQuestions += "<tr><td></td><td align='right'></td><td align='left' class='essay_responses'>" + tempArray[responses] + "</td></tr>"
						
					}
					
					eQuestions += "</table></div>"
			
				}
				$("#EssayWrapper").append(eQuestions);
			});
		}
	*/	
    function mainQuery(crn, semester, year)
    {
      jQuery.get('https://chitester1dev.weber.edu:6838/misc/weber/CSEvals/AnswerCount.cfm?crn='+crn+'&semester='+semester+'&year='+year+'&testId='+testId, function(data) {$.each(data.DATA, function(i,array)
			{
				window.currentQuestion = array[2];
				$.each(data.DATA, function(i,innerArray) {
					if(window.currentQuestion == innerArray[2] && window.finishedQuestions.indexOf(window.currentQuestion + " - " + innerArray[3]) == -1)
					{
						switch(innerArray[3])
						{
							case 'strongly disagree' :
							case 'very poor' :
								window.currentSD+= +innerArray[4];
								window.currentTotal+= +innerArray[4];
								break;
							case 'disagree' :
							case 'poor' :
								window.currentD+= +innerArray[4];
								window.currentTotal+= +innerArray[4];						  
								break;
							case 'neutral' :
							case 'average' :
								window.currentN+= +innerArray[4];
								window.currentTotal+= +innerArray[4];
								break;
							case 'agree' :
							case 'good' :
								window.currentA+= +innerArray[4];
								window.currentTotal+= +innerArray[4];
								break;					
							case 'strongly agree' :
							case 'excellent' :
								window.currentSA+= +innerArray[4];
								window.currentTotal+= +innerArray[4];
								break;
						}
						window.finishedQuestions.push(window.currentQuestion + " - " + innerArray[3]);
					}
				});
			
				if(window.printedQuestions.indexOf(window.currentQuestion) == -1)
				{
					questionCollapserId++;
					totalQuestions++;
					window.currentLengths = getPixelLengthBasic();
					window.printedQuestions.push(window.currentQuestion);
					$("#array").append('<p style="clear:both;">' + window.currentQuestion + " - " + window.currentSD + " - " + window.currentD + " - "  + window.currentN + " - " + window.currentA +" - " + window.currentSA +" - " + window.currentTotal + "</p><br>" );
					appendQuestion();
				}
			
				window.currentQuestion = " ";
				window.currentSD = 0;
				window.currentD = 0;
				window.currentN = 0;
				window.currentA = 0;
				window.currentSA = 0;
				window.currentTotal = 0;
      });
		}).success(function(){bindButtons();});
	}
	
    var CRN = 30594;
    var Semester = 3;
    var Year = 2013;
	var testId = 64529;
    var totalBarLength = 400;
    var currentQuestion = " ";
    var currentSD = 0;
    var currentD = 0;
    var currentN = 0;
    var currentA = 0;
    var currentSA = 0;
    var currentTotal = 0;
    var currentLengths = [ ];
    var finishedQuestions = [ ];
    var printedQuestions = [ ];
		var questionCollapserId = 0;
		var totalQuestions = 0;
		
    function topQuery(crn,semester,year)
    {
      jQuery.get('https://chitester1dev.weber.edu:6838/misc/weber/CSEvals/CrnStatistics.cfm?crn='+crn+'&semester='+semester+'&year='+year+'&testId='+testId, function(data) 
			{
				$.each(data.DATA, function(i,array) 
				{
					$("#StatisticsWrapper").append('<table style="top_table_settings" align="center"><tr><td style="width: 40px"></td><td style="width: 300px;"></td><td></td><td></td><td style="max-width:100px;text-align:center;">Standard Deviation</td></tr><tr><td style="width: 40px"><div class="expander"><div class="minus">-</div></div></td><td class="bigger bolder" align="left">Your Overall Score</td><td class="bigger bolder" style="width: 60px">'+Number(array[7]).toFixed(2)+'</td><td><div class="container ticks"><div class="overall_ bigbar yellow ticks" style="width:'+getPixelLength(array[7])+'px;"></div></div></td><td style="width: 100px;">'+Number(array[8]).toFixed(2)+'</td></tr></table>');
					$("#StatisticsWrapper").append('<table style="top_table_settings" class="border spacing" align="center"><tr><td style="width: 40px;"></td><td align="left" style="padding-left: 30pt;">Method Subscore (Q:1-4)</td><td style="width: 60px;">'+Number(array[0]).toFixed(2)+'</td><td><div class="container"><div class="overall_bar yellow" style="width:'+getPixelLength(array[0])+'px;"></div></div></td><td style="width: 100px;">Fix Me</td></tr><tr><td style="width: 40px;"></td><td align="left" style="padding-left: 30pt;">Instructor Subscore (Q:5-11)</td><td style="width: 60px;">'+Number(array[1]).toFixed(2)+'</td><td><div class="container"><div class="overall_bar yellow" style="width:'+getPixelLength(array[1])+'px"></div></div></td><td style="width: 100px;">Fix Me</td></tr><tr><td style="width: 40px;"></td><td align="left" style="padding-left: 30pt;">Content Subscore (Q:12-15)</td><td style="width: 60px;">'+Number(array[2]).toFixed(2)+'</td><td><div class="container"><div class="overall_bar yellow" style="width:'+getPixelLength(array[2])+'px"></div></div></td><td style="width: 100px;">Fix Me</td></tr><tr class="gap"><td style="width: 40px;"></td><td align="left" style="width: 300px;">Your Overall Semester Average</td><td style="width: 60px;">'+Number(array[3]).toFixed(2)+'</td><td><div class="container"><div class="overall_bar " style="width:'+getPixelLength(array[3])+'px"></div></div></td><td style="width: 100px;">'+Number(array[4]).toFixed(2)+'</td></tr><tr><td style="width: 40px;"></td><td align="left" style="width: 300px;">Departmental Semester Average</td><td style="width: 60px;">'+Number(array[5]).toFixed(2)+'</td><td><div class="container"><div class="overall_bar" style="width:'+getPixelLength(array[5])+'px"></div></div></td><td style="width: 100px;">'+Number(array[6]).toFixed(2)+'</td></tr><tr><td style="width: 40px;"></td><td align="left" style="width: 300px;">Deparmental CS 1400 5 Year Average</td><td style="width: 60px;">Fix Me</td><td><div class="container"><div class="overall_bar" style="width:333"></div></div></td><td style="width: 100px;">Fix Me</td></tr><tr><td style="width: 40px;"></td><td align="left" style="width: 300px;">Your CS 1400 5 Year Average</td><td style="width: 60px;">Fix Me</td><td ><div class="container"><div class="overall_bar" style="width:270"></div></div></td><td style="width: 100px;">Fix Me</td></tr><tr><td class="bolder" colspan="5">FIX THIS A score of 3.92 places you in the 90th percentile of your department this semester.</td></tr></table>');
					$("#loadinggif").remove();
				});
      });
    }
	
    window.onload=(function() {
      $("#StatisticsWrapper").before('<img id="loadinggif" src="http://www.familytv.com/App_Support/Images/default/Loading_White.gif" "/>');
			mainQuery(CRN,Semester,Year);
			essayQuery(CRN, Semester, Year);		
			topQuery(CRN,Semester,Year);
    });
  </script>
</head>

<body class="body">
  <div class="wrapper">
   
		<div class="header">
		
      <a href="teacher-dashboard.html"><img src="images/wevallogo.png" alt="Logo"/></a>	
     
			<div class="filter">
				<form name="input" action="" method="">
					<select id="courseInstructor">
						<option value="teacherName">Brad Peterson</option>
					</select>			
					<select id="semester">
						<option value="semester1">Summer 2013</option>
						<option value="semester2">Spring 2013</option>
						<option value="semester3">Fall 2012</option>
					</select>
					<select id="course">
						<option value="course1">CS4790</option>
						<option value="course2">CS4110</option>
						<option value="course3">CS4800</option>
					</select>
					<input type="submit" value="Submit"/>
				</form>
			</div>
    </div>
		
    <div class="bar_header"><hr/></div>
		
    <div class="expand_all">
			<table>	
				<tr>
					<td><input id="expandAll" onClick="expandAllQuestions()" type="checkbox"/>expand all</td>
				</tr>
			</table>
		</div>
	
		<div class="title">Course Evaluation - CS1400 67877 Spr 2013</div>
		<div id="StatisticsWrapper"></div>
		<div class="bar_divider"><hr/></div>
		<div class="legend_box">
			<div class="legend_graph">
				<div class="graph_box graphStronglyDisagree">Strongly Disagree</div>	
				<div class="graph_box graphDisagree">Disagree</div>
				<div class="graph_box graphNeutral">Neutral</div>
				<div class="graph_box graphAgree">Agree</div>
				<div class="graph_box graphStronglyAgree">Strongly<br/> Agree</div>					
			</div>
		</div>
	
		<div id="questions_wrapper"></div>
		<div class="question_box">
		
			<div class="expander"><div class="minus">-</div></div>
				
				<table class="table_settings" border="0">			
					<tr>	
						<td colspan="6">
							<div class="question">
									Course objectives were clearly communicated
							</div>
						<td>
					</tr>
					
					<tr>
						<td align='left' width='225px'> </td>
						<td align='left' width='47' class="">SD</td>	
						<td align='left' width='47' class="">D</td>
						<td align='left' width='47' class="">N</td>
						<td align='left' width='47' class="">A</td>
						<td align='left' width='47' class="">SA</td>	
						<td align='left'></td>
					</tr>
								
					<tr>
						<td align='left' width='225px'> </td>
						<td align='left' width='47'>8</td>	
						<td align='left' width='47'>3</td>
						<td align='left' width='47'>6</td>
						<td align='left' width='47'>3</td>
						<td align='left' width='47'>2</td>	
						<td align='left' rowspan="2"> 
						
						<div class="graph_expanded">
								<div class="graph_box graphStronglyDisagree"></div>	
								<div class="graph_box graphDisagree"></div>
								<div class="graph_box graphNeutral"></div>
								<div class="graph_box graphAgree"></div>
								<div class="graph_box graphStronglyAgree"></div>				
						</div>
						
						</td>
					</tr>							
					<tr>
						<td align='left' width='225px'> </td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	

					</tr>	
					
					<tr>
						<td align='left' width='100px'>Dpt Average This Semester</td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	
						<td align='left'> 
						
							<div class="graph_expanded">
									<div class="graph_box_expanded graphStronglyDisagreeExpanded"></div>	
									<div class="graph_box_expanded graphDisagreeExpanded"></div>
									<div class="graph_box_expanded graphNeutralExpanded"></div>
									<div class="graph_box_expanded graphAgreeExpanded"></div>
									<div class="graph_box_expanded graphStronglyAgreeExpanded"></div>				
							</div>
						
						</td>
					</tr>
					
					<tr>
						<td align='left' width='100px'>Your Overall Semester Average</td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	
						<td align='left'> 
						
							<div class="graph_expanded">
									<div class="graph_box_expanded graphStronglyDisagreeExpanded"></div>	
									<div class="graph_box_expanded graphDisagreeExpanded"></div>
									<div class="graph_box_expanded graphNeutralExpanded"></div>
									<div class="graph_box_expanded graphAgreeExpanded"></div>
									<div class="graph_box_expanded graphStronglyAgreeExpanded"></div>				
							</div>
						
						</td>
					</tr>	
						
					<tr>
						<td align='left' width='100px'>Dpt CS 1400 5 Year Average</td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	
						<td align='left'> 
						
							<div class="graph_expanded">
									<div class="graph_box_expanded graphStronglyDisagreeExpanded"></div>	
									<div class="graph_box_expanded graphDisagreeExpanded"></div>
									<div class="graph_box_expanded graphNeutralExpanded"></div>
									<div class="graph_box_expanded graphAgreeExpanded"></div>
									<div class="graph_box_expanded graphStronglyAgreeExpanded"></div>				
							</div>
						
						</td>
					</tr>
					
					<tr>
						<td align='left' width='100px'>Your CS 1400 5 Year Average</td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	
						<td align='left'> 
						
							<div class="graph_expanded">
									<div class="graph_box_expanded graphStronglyDisagreeExpanded"></div>	
									<div class="graph_box_expanded graphDisagreeExpanded"></div>
									<div class="graph_box_expanded graphNeutralExpanded"></div>
									<div class="graph_box_expanded graphAgreeExpanded"></div>
									<div class="graph_box_expanded graphStronglyAgreeExpanded"></div>				
							</div>
						
						</td>
					</tr>	
					
					<tr>
						<td align='left' width='100px'>College Average Spring 2013</td>
						<td align='left' width='47'>8%</td>	
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>6%</td>
						<td align='left' width='47'>3%</td>
						<td align='left' width='47'>2%</td>	
						<td align='left'> 
						
							<div class="graph_expanded">
									<div class="graph_box_expanded graphStronglyDisagreeExpanded"></div>	
									<div class="graph_box_expanded graphDisagreeExpanded"></div>
									<div class="graph_box_expanded graphNeutralExpanded"></div>
									<div class="graph_box_expanded graphAgreeExpanded"></div>
									<div class="graph_box_expanded graphStronglyAgreeExpanded"></div>				
							</div>
						
						</td>
					</tr>		
											
				</table>				
		</div>
		
		<div class="bar_divider"><hr/></div>

		<div id="EssayWrapper"></div>
		
		<div class="footer">
			&copy; 2013 Weber State University
		</div>
  </div>
</body>
</html>
